/*
 * @Author: 谢小康 2170673706@qq.com
 * @Date: 2023-12-08 14:05:01
 * @LastEditors: 谢小康 2170673706@qq.com
 * @LastEditTime: 2024-01-21 17:19:51
 * @FilePath: \My-bolg\server\router\users.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const express = require('express');
const router = express.Router();
const {
    tologin,
    adjustLogin,
    refreshtoken,
    getAuthByuserid,
    getqiniutoken,
    getuser,
    updateuser,
    changepassword,
    registerusr,
    getdata,
    getallusers,
    getusernum,
    deleteusers,
    deleteuserscorver,
    tochangerole,
    isuser,
    canuser
}=require("../controller/user.js")
const {
    ParameterValidation,
    auth,
} = require("../util/user.js");
let {everfygetprams,confirmprams} = require("../middleware/friend.js")
const {isSuperAdmin} = require('../controller/user.js')
/* 用户登录 */
router.post('/login',ParameterValidation,tologin);
/* 判断用户是否登录 */
router.get("/islogin",adjustLogin)
/* 刷新token */
router.get("/refreshtoken",refreshtoken)
/* 根据用户id查询权限,返回路由权限 */
router.post("/getAuthByuserid",auth,getAuthByuserid)
/* 获取上传七牛云的token */
router.get("/getqiniutoken",getqiniutoken)
/* 获取用户 */
router.get("/getuser",auth,getuser)
/* 修改用户信息 */
router.post("/updateuser",auth,updateuser)
/* 修改密码 */
router.post("/changepassword",auth,changepassword)
/* 注册用户 */
router.post("/registerusr",registerusr)
/* 获取首页数据 */
router.get("/getdata",getdata) 
/* 获取数据 */
router.get("/getallusers",auth,everfygetprams,getallusers)
/* 获取用户数量 */
router.get("/getusernum",auth,getusernum)
/* 删除用户 */
router.post("/deleteusers",auth,isSuperAdmin,confirmprams,deleteusers)
/* 删除用户头像 */
router.post("/deleteuserscorver",auth,isSuperAdmin,deleteuserscorver)
/* 修改用户权限 */
router.post("/tochangerole",auth,isSuperAdmin,tochangerole)
router.post("/isuser",auth,isuser)
router.post("/canuser",canuser)
module.exports = router